package com.packet.controller;

import com.packet.pojo.Staff;
import com.packet.service.ManagerStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class ChooseManagerController {
    @Autowired
    ManagerStaffService managerStaffService;

    @GetMapping("/selectManager")
    public String SelectManager(Model model){
        List<Staff> staffs = managerStaffService.selectManager();
        model.addAttribute("staffs",staffs);
        return "manager/list";
    }

    @GetMapping("/choose/{id}")
    public String ChooseManager(@PathVariable("id") Integer id, HttpSession session){
        Integer sid = (Integer)session.getAttribute("sid");
        managerStaffService.chooseManager(sid,id);
        return "manager/chooseSuccess";
    }
}
